package com.blrs.web.core.config;

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.EnvironmentPBEConfig;

public class Test {
    public static void main(String[] args) {
        // 实例化加密器
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();

        // 配置加密算法和秘钥
        EnvironmentPBEConfig config = new EnvironmentPBEConfig();
        config.setAlgorithm("PBEWithMD5AndDES");    // 设置加密算法，默认的
        config.setPassword("ueiej@8e8r");      // 用于加密的秘钥（盐），可以是随机字符串，一定要记住并且存储好
        encryptor.setConfig(config);

        // 对自己的密码进行加密
        String myPwd = "Cblz_2025";
        String encryptedPwd = encryptor.encrypt(myPwd);
        System.out.println("++++++++++++++++++++++++++++++");
        System.out.println("+ 原密码为：" + myPwd);
        System.out.println("+ 加密后的密码为：" + encryptedPwd);
        System.out.println("++++++++++++++++++++++++++++++");

        // 备注：此方式也可以用于账号密码登录的加盐操作
    }
}
